H-6623: Fix uploading and making user and org avatars public#8913
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 1ba9241. Bugbot is set up for automated code reviews on this repo. Configure here. |
TimDiekmann
left a comment
There was a problem hiding this comment.
Looks good, that should help until we have a proper public flag or something similar 🚀
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 33ba797. Configure here.
There was a problem hiding this comment.
Pull request overview
This PR fixes avatar uploads (user + org) by adding a makePublic flag to relevant GraphQL mutations and ensuring public-view policies are created during entity creation (instead of attempting to add a public viewer afterwards, which was crashing).
Changes:
- Add
makePublic: Boolean = falseto GraphQL schema forcreateEntity,requestFileUpload, andcreateFileFromUrl. - Update frontend upload flows to pass
makePublicthrough mutations and remove the post-create “add public viewer” step. - Update API resolvers and file creation logic to plumb
makePublicdown and create a public-view policy at entity creation time.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/@local/hash-isomorphic-utils/src/graphql/type-defs/knowledge/file.typedef.ts | Adds makePublic argument to file upload/link creation mutations in the shared schema. |
| libs/@local/hash-isomorphic-utils/src/graphql/type-defs/knowledge/entity.typedef.ts | Adds makePublic argument to createEntity in the shared schema. |
| apps/hash-frontend/src/shared/file-upload-context.tsx | Removes addEntityViewer follow-up mutation and passes makePublic directly to create/upload mutations. |
| apps/hash-frontend/src/graphql/queries/knowledge/file.queries.ts | Adds $makePublic variable and passes it to requestFileUpload / createFileFromUrl. |
| apps/hash-frontend/src/graphql/queries/knowledge/entity.queries.ts | Adds $makePublic variable and passes it to createEntity. |
| apps/hash-api/src/graphql/resolvers/knowledge/file/request-file-upload.ts | Threads makePublic into the underlying file upload creation call. |
| apps/hash-api/src/graphql/resolvers/knowledge/file/create-file-from-url.ts | Threads makePublic into the underlying external-url file creation call. |
| apps/hash-api/src/graphql/resolvers/knowledge/entity/entity.ts | Adds makePublic support to createEntityResolver via creation-time policies. |
| apps/hash-api/src/graph/knowledge/system-types/file.ts | Adds creation-time public-view policy support for file entities created from uploads/URLs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8913 +/- ##
==========================================
- Coverage 59.76% 59.65% -0.12%
==========================================
Files 1348 1350 +2
Lines 131800 132047 +247
Branches 5943 5950 +7
==========================================
+ Hits 78772 78773 +1
- Misses 52120 52366 +246
Partials 908 908
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
apps/hash-api/src/graph/knowledge/system-types/file.ts:418
- In this function
makePublicis only applied in thecreateEntitybranch; whenexistingEntityis present the code updates the entity and does not validate or enforce the requested public visibility. If the Graph can’t add view policies after creation (per PR description), it would be safer to either verify the entity is already public whenmakePublicis true or fail fast with a clear error so the caller can choose to create a new entity instead.
return existingEntity
? await updateEntity<File>(ctx, authentication, {
entity: existingEntity,
entityTypeIds,
Only pass the pre-generated entityUuid and public policies to the root entity in createEntityWithLinks. Nested entities and link entities now receive their own UUIDs from the graph store instead of reusing the root entity UUID. Co-authored-by: Ciaran Morinan <CiaranMn@users.noreply.github.com>
Co-authored-by: Ciaran Morinan <CiaranMn@users.noreply.github.com>
Co-authored-by: Ciaran Morinan <CiaranMn@users.noreply.github.com>

🌟 What is the purpose of this PR?
The public view policy needs to be created at the same time as creating the entity – adding the viewer afterwards is not currently supported, and was causing a crash.
Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
❓ How to test this?